package com.hongye.consult.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import com.hongye.common.enu.ResultEnum;
import com.hongye.common.utils.ResponseResult;
import com.hongye.consult.service.HouseService;
import com.hongye.consult.vo.HotHomeVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 
 *
 * @author hxy
 * @email 3199037134@qq.com
 * @date 2022-04-26 18:42:18
 */
@RestController
@RequestMapping("consult/house")
public class HouseController {

     @Autowired
    HouseService houseService;

    /**
     * 首页热门房屋
     * @return
     */
    @GetMapping("/hothome")
    public ResponseResult hotHome(){
        ResponseResult<Object> result = new ResponseResult<>();
        try{

//            查询结果
            List<HotHomeVo> hotHomeVoList=houseService.hotHome();
            result.setSuccess(ResultEnum.SUCCESS.getSuccess());
            result.setCode(ResultEnum.SUCCESS.getCode());
            result.setMessage(ResultEnum.SUCCESS.getMessage());
            result.setData(hotHomeVoList);
            return result;
        }catch (Exception e){

//            出错返回结果
            e.printStackTrace();
            result.setSuccess(ResultEnum.ERROR.getSuccess());
            result.setCode(ResultEnum.ERROR.getCode());
            result.setMessage(ResultEnum.ERROR.getMessage());
            return result;
        }

    }
}
